package iterator

type Itrapo interface {
	Iterator() MyIterator
}

type MyIterator interface {
	IsDone() bool
	Next() interface{}
	First()
}
type SinNumbersItrator struct {
	start, end int
}

func NewSinNumbersItrator(start int, end int) *SinNumbersItrator {
	return &SinNumbersItrator{start: start, end: end}
}
func (s *SinNumbersItrator) Iterator() MyIterator {
	return &SinNumberItrator{
		number: s,
		next:   s.start,
	}
}

type SinNumberItrator struct {
	number *SinNumbersItrator
	next   int
}

func (i *SinNumberItrator) First() {
	i.next = i.number.start
}
func (i *SinNumberItrator) IsDone() bool {
	return i.next > i.number.end
}
func (i *SinNumberItrator) Next() interface{} {
	if !i.IsDone() {
		next := i.next
		i.next++
		return next
	}
	return nil
}

// 可以 start end
// number  sin conn
// 我们可以
// sinkiter
// statrtr end
// rit r
// mnyi
// netx  i.nte
// nte.iomy
// is one
// netx ntext netxnmet
// netx
// netx++
// next =
// 1 2 3 4 5 6
// statr = 1 end =6
// next = statr
// netx++
// renrnnext
// isno
// next > end
// sidone
// firse
// if i,ir !io.one
// next
// ++
// n++
//
